package com.wokeMy.view.adpter;

import android.content.Context;
import android.text.Html;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.wokeMy.view.model.DoubleLo;
import com.wokeMy.view.util.Util;
import com.zhongcai.online.R;

import java.util.ArrayList;


/**
 * Created by Administrator on 2017-11-18.
 */

public class LastBatAdapter extends BaseAdapter {
    private LayoutInflater inflater;
    private ArrayList<DoubleLo> data;
    public LastBatAdapter(Context context, ArrayList<DoubleLo> data) {
        this.inflater=LayoutInflater.from(context);
        this.data=data;

    }

    @Override
    public int getCount() {
        return data.size();
    }

    @Override
    public Object getItem(int position) {
        return null;
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHold viewHold;
        if (convertView==null){
            viewHold=new ViewHold();
            convertView=inflater.inflate(R.layout.item_last_bat,null);
            viewHold.qishuTv=(TextView) convertView.findViewById(R.id.qishu_last_tv);
            viewHold.redTv=(TextView) convertView.findViewById(R.id.red_last_tv);
            convertView.setTag(viewHold);
        }else {
            viewHold=(ViewHold)convertView.getTag();
        }
        DoubleLo doubleLo = data.get(position);
        viewHold.qishuTv.setText("第"+doubleLo.getIssue()+"期开奖结果：");
        if (doubleLo.getStatus().equals("2")){
            viewHold.redTv.setText("待开奖");
        }else {
            if (doubleLo.getLotteryid().equals("118")){
                viewHold.redTv.setText(Html.fromHtml(Util.dealtIssue(doubleLo.getBonuscode())));
            }else  if (doubleLo.getLotteryid().equals("106")){
                viewHold.redTv.setText(Html.fromHtml(Util.dealtIssueDuo(doubleLo.getBonuscode(),2)));
            }
        }

        return convertView;
    }
    class ViewHold {
        TextView qishuTv;
        TextView redTv;
    }

}
